#include <am.h>
#include <amdev.h>
#include <klib.h>

#define Assert(x, y) if(x) ;else {printf("\n"#x" not satisfied! "y"\n");assert(0);}

typedef int bool;
#define false 0
#define true 1
#define FPS 60


// avatar.c
struct Avatar {
    bool dead;
    int x;
    int y;
    double vx;
    double vy;
    bool flying;
    int init_y;
    int a;
} avatar;
typedef struct Avatar Avatar;
void reset_avatar(int x, int y, int vx, int a);
void jump(int vy);
void update();


// video.c
extern int width;
extern int height;
extern int off_x;
extern int off_y;
void init_map();
void draw_avatar();
void undraw_avatar();
void draw_map(int lvl);
void undraw_map(int lvl);
void draw_bg();

// logic.c
bool crash();
bool hit();

static inline int my_read_key() {
  _DEV_INPUT_KBD_t key;
  _io_read(_DEV_INPUT, _DEVREG_INPUT_KBD, &key, sizeof(_DEV_INPUT_KBD_t));
  int ret = key.keycode | (key.keydown<<8);
  return ret;
}